<include file="public@header"/>
</head>
<body>
<div class="layui-fluid js-check-wrap">
    <div class="layui-card">
        <div class="layui-card-header">
            <h3>{:lang('ADMIN_LINK_INDEX')}</h3>
        </div>
        <div class="layui-card-body">
            <form class="form-search layui-form clearfix" action="{:url('Link/index')}">
                <div class="layui-col-md8 layui-col-sm8">
                    <div class="layui-inline">
                        <input type="text" class="layui-input" name="keyword" style="width: 160px;"
                           value="{$keyword|default=''}" placeholder="{:lang('PLEASE_ENTER_KEYWORD')}">
                    </div>
                    <div class="layui-inline">
                        <select class="layui-input" name="type" style="width: auto;">
                            <option value=''>{:lang('SELECT_PLEASE')}{:lang('LINK_TYPE')}</option>
                            <option value='1' <eq name="type" value="1">selected</eq> >{:lang('TEXT_LINK')}</option>
                            <option value='2' <eq name="type" value="2">selected</eq> >{:lang('PICTURE_LINK')}</option>
                        </select>
                    </div>
                    <div class="layui-inline">
                        <select class="layui-input" name="category" style="width: 140px;">
                            <option value=''>{:lang('PLEASE_SELECTED_CATEGORY')}</option>
                            {$catOptions|default=''}
                        </select>
                    </div>
                    <!-- 用于列表排序 -->
                    <!-- <input type="hidden" name="sort_by" value="{$filter.sort_by}">
                    <input type="hidden" name="list_order" value="{$filter.list_order}"> -->
                    <!-- 用于列表排序 -->
                    <div class="layui-inline">
                        <input type="submit" class="layui-btn layui-btn-normal" value="{:lang('SEARCH')}"/>
                    </div>
                    <!-- <a class="layui-btn layui-btn-danger layui-btn-sm" href="{:url('Link/index')}">{:lang('EMPTY')}</a> -->
                </div>

                <div class="layui-col-md4 layui-col-sm4 text-right">
                    <if condition="in_array('add', $actions)">
                        <a class="layui-btn layui-btn-normal inline-block" href="{:url('link/add',array('category'=>$category,type=>'2'))}">{:lang('ADD')}{:lang('PICTURE_LINK')}</a>
                        <a class="layui-btn layui-btn-normal inline-block" href="{:url('link/add',array('category'=>$category,type=>'1'))}">{:lang('ADD')}{:lang('TEXT_LINK')}</a>
                    </if>
                </div>
            </form>
        </div>
        <form method="post" class="js-ajax-form" action="{:url('Link/listOrder')}">
            <table class="layui-table">
                <thead>
                <tr>
                    <th width="20" class="text-center">
                        <div class="custom-checkbox">
                            <input type="checkbox" id="checkall" class="js-check-all" data-direction="x" data-checklist="js-check-x">
                            <label for="checkall"></label>
                        </div>
                    </th>
                    <!-- 排序 -->
                    <if condition="in_array('list_order',$list_item)">
                        <th width="50" class="text-center">{:lang('SORT')}</th>
                    </if>
                    
                    <!-- <th width="50">ID</th> -->

                    <!-- 名称 -->
                    <if condition="in_array('name',$list_item)">
                        <th>{:lang('LINK_NAME')}</th>
                    </if>

                    <!-- 分类名称 -->
                    <if condition="in_array('category',$list_item)">
                        <th>{:lang('CATEGORY')}</th>
                    </if>

                    <!-- 地址 -->
                    <if condition="in_array('url',$list_item)">
                        <th>{:lang('LINK_URL')}</th>
                    </if>

                    <!-- 状态 -->
                    <if condition="in_array('status',$list_item)">
                        <th>{:lang('DISPLAY_HIDE')}</th>
                    </if>

                    <th width="100">{:lang('ACTIONS')}</th>
                </tr>
                </thead>
                <tbody>
                <foreach name="links" item="vo">
                    <tr>
                       <td class="text-center">
                           <div class="custom-checkbox">
                               <input type="checkbox" class="js-check" data-yid="js-check-y" data-xid="js-check-x" name="ids[]" id="chk_{$vo.id}"
                                  value="{$vo.id}" title="ID:{$vo.id}">
                               <label for="chk_{$vo.id}"></label>
                           </div>
                        </td>
                        <!-- 排序 -->
                        <if condition="in_array('list_order',$list_item)">
                            <td>
                                <input name='list_orders[{$vo.id}]' class="input input-order" type='text' value='{$vo.list_order}'>
                           </td>
                        </if>
                        <!-- <td>{$vo.id}</td> -->

                        <!-- 名称 -->
                        <if condition="in_array('name',$list_item)">
                            <td>{$vo.name}</td>
                        </if>

                        <!-- 分类名称 -->
                        <if condition="in_array('category',$list_item)">
                            <td>{$vo.cat_name}</td>
                        </if>
                        <!-- 地址 -->
                        <if condition="in_array('url',$list_item)">
                            <td><a href="{$vo.url}" target="_blank">{$vo.url}</a></td>
                        </if>

                        <!-- 状态 -->
                        <td>
                            <notempty name="vo.status">
                                <span class="layui-btn layui-btn-normal layui-btn-xs">{:lang('DISPLAY')}</span>
                                <else/>
                                <span class="layui-btn layui-btn-xs layui-btn-danger">{:lang('HIDE')}</span>
                            </notempty>
                        </td>

                        <td>
                            <if condition="in_array('edit', $actions)">
                                <a href="{:url('link/edit',array('id'=>$vo['id']))}" class="layui-btn layui-btn-xs">{:lang('EDIT')}</a>
                            </if>
                            <if condition="in_array('delete', $actions)">
                                <a href="{:url('link/delete',array('id'=>$vo['id']))}" class="js-ajax-delete layui-btn layui-btn-danger layui-btn-xs">
                                    {:lang('DELETE')}
                                </a>
                            </if>
                        </td>
                    </tr>
                </foreach>
                </tbody>
            </table>
        
            <div class="pagination-row clearfix">
                <div class="layui-col-sm6 text-left-sm">
                    <!-- <a class="layui-btn layui-btn-primary" data-table-name="link" href="javascript:;" onclick="setListItem(this,'400px','380px')">列表项</a> -->

                    <!--批量操作-->
                    <div class="btn-group dropup marginTB-xs" id="edit_more">
                        <button type="button" class="layui-btn layui-btn-normal dropdown-toggle" data-toggle="dropdown">
                            批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <if condition="in_array('toggle', $actions)">
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                            data-action="{:url('link/toggle',array('display'=>1))}" data-subcheck="true">{:lang('MARKUP_DISPLAY')}
                                    </button>
                                </li>
                                <li>
                                    <button class="js-ajax-submit" type="submit"
                                        data-action="{:url('link/toggle',array('hide'=>1))}" data-subcheck="true">{:lang('MARKUP_HIDE')}
                                    </button>
                                </li>
                                <li class="divider"></li>
                            </if>
                        </ul>
                    </div>

                    <!-- 排序 -->
                    <if condition="in_array('listOrder', $actions)">
                        <if condition="in_array('list_order',$list_item)">
                            <button class="layui-btn layui-btn-warm js-ajax-submit" type="submit"
                                    data-action="{:url('link/listOrder')}">{:lang('SAVE_SORT')}
                            </button>
                        </if>
                    </if>

                    <!-- 删除选中项 -->
                    <if condition="in_array('delete', $actions)">
                        <button class="layui-btn layui-btn-danger js-ajax-submit" type="submit"
                                data-action="{:url('link/delete')}" data-subcheck="true" data-msg="您确定删除吗？">
                            {:lang('DELETE_SELECTED')}
                        </button>
                    </if>
                </div>

                <div class="pages">{$page|default=''}</div>
            </div>
        </form>
    </div>
</div>
<include file="public@footer"/>
